package cate.game.role.res.call.base;

import cate.common.table.call.row.CallBaseRow;
import cate.common.util.GameResult;
import cate.game.res.CostSelect;
import cate.game.res.MixRes;
import cate.game.res.MixResItem;
import cate.game.role.Role;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.LinkedList;
import java.util.List;

@NoteClass(value = "抽取过程中使用和记录的数据")
public class CallProcessData {

    @NoteField(value = "抽取的基础信息")
    public CallBaseRow base;

    @NoteField(value = "最多能抽几次")
    private int maxTime;

    @NoteField(value = "当前实际抽了几次")
    public int consumedTimes;

    @NoteField(value = "召唤消耗")
    public MixRes cost = new MixRes();

    @NoteField(value = "召唤所得奖励-未发过的")
    public MixRes reward = new MixRes();

    @NoteField(value = "召唤所得奖励-已经发过的")
    public MixRes sentReward = new MixRes();

    @NoteField(value = "耗材选择", detail = "选择指定英雄")
    public CostSelect cs;

    @NoteField(value = "召唤结果")
    public List<CallResult> result = new LinkedList<>();

    public CallProcessData() {
    }

    public CallProcessData(CostSelect cs) {
        this.maxTime = base.callTimes;
        this.cs = cs;
    }

    public boolean checkFinish() {
        return this.consumedTimes < this.getMaxTime();
    }

    public void addCost(MixResItem item) {
        this.cost.addItem(item);
    }

    public void addCost(MixRes cost) {
        this.cost.addList(cost);
    }

    public void addReward(MixRes reward) {
        this.reward.addList(reward);
    }


    public boolean checkMad() {
        return base.callTimes > base.costPropNum;
    }

    public int allRewardScore() {
        return checkMad() ? base.rewardScore * maxTime : base.rewardScore;
    }

    public void setBase(CallBaseRow base) {
        this.base = base;
    }

    public int getMaxTime() {
        return maxTime;
    }

    public void setMaxTime(int min) {
        maxTime = min;
    }

    public GameResult consumeCost(Role role) {
        return this.cost.consume(role, this.cs);
    }
}
